#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
using namespace std;

int main()
{
        int n = 0;
        cin >> n;
        vector<vector<int>> gh(256);
        vector<int> indegree(256, 0);
        set<char> chset;

        string pre, cur;
        cin >> pre;
        for(int i = 1; i < n; i++){
                cin >> cur;
                int len = min(pre.length(), cur.length());
                for(int j = 0; j < len; j++){
                        chset.insert(pre[j]);
                        chset.insert(cur[j]);
                        if(pre[j] != cur[j]){
                                gh[pre[j]].push_back(cur[j]);
                                indegree[cur[j]]++;
                                break;
                        }
                }
                pre = cur;
        }
        string org, virs;
        cin>>virs;

        queue<char> q;
        for(auto ch : chset){
                if(indegree[ch] == 0){
                        q.push(ch);
                }
        }
        if(q.size() > 1){
                cout<<0<<endl;
                return 0;
        }

        char alpha = 'a';
        map<char, char> mp;
        while(!q.empty()){
                char ch = q.front();
                q.pop();
                mp[ch] = alpha++;

                for(auto v : gh[ch]){
                        if(--indegree[v] == 0){
                                q.push(v);
                        }
                }
        }

        for(auto ch : virs){
                if(mp[ch]){
                        org.push_back(mp[ch]);
                }else{
                        cout<<0<<endl;
                        return 0;
                }
        }
        cout<<org<<endl;
        return 0;
}